#include <bits/stdc++.h>

#define ll long long
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
const int INF = 1e9;
using namespace std;
/*思考区
最优策略：摘最大值
如果一开始tom没输
那么最后就看谁没有操作了>>sum是奇是偶
*/
void solve()
{
    int n,k;
    cin >> n >> k;
    vector<int> a(n+1,0);
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    int sum=accumulate(a.begin(), a.end(), 0);
    sort(a.begin() + 1, a.end());
    a[n]--;
    sort(a.begin() + 1, a.end());
    if(a[n]-a[1]>k||!(sum%2))
    {
        cout<<"Jerry"<<endl;
        return;
    }
    cout<<"Tom"<<endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 0;
    cin >> t;
    while (t--)
        solve();
    return 0;
}